import { createRouter, createWebHashHistory } from 'vue-router'
// import HomeView from '../views/HomeView.vue'
import Login from '@/views/Login/Login.vue'
import Home from '@/views/Home/Home.vue'
import Category from '@/views/Category/Category.vue'
// const Layout = () => import('@/views/Layout/Layout.vue') // 路由懒加载 也可以省略const 直接写在路由里面
const routes = [
  {
    path: '/login',
    name: 'login',
    component: Login
  },
  {
    path: '/',
    name: 'Layout',
    component: () => import('@/views/Layout/Layout.vue'),
    children: [
      {
        path: '', // /#/ path为空，默认展示这个组件
        name: 'home',
        component: Home
      },
      {
        path: '/category', // /#/category
        name: 'category',
        component: Category
      }
    ]
  }
  // {
  //   path: '/about',
  //   name: 'about',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  // }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
